<include file="public@header"/>
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
</style>
<script type="text/html" id="photos-item-tpl">
    <li id="saved-image{id}">
        <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">

        <input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
               style="width: 200px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
             onclick="imagePreviewDialog(this.src);">
        <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>
</script>
<script type="text/html" id="files-item-tpl">
    <li id="saved-file{id}">
        <input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
        <input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
               style="width: 200px;" title="文件名称">
        <a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
        <a href="javascript:uploadOne('文件上传','#file-{id}','file');">替换</a>
        <a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
    </li>
</script>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('BatMatch/index')}">对战列表</a></li>
        <li class="active"><a href="#">编辑对战</a></li>
    </ul>
    <form action="{:url('BatMatch/update')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
        <div class="row">
            <div class="col-md-9">
                <table class="table table-bordered">
                    <input type="hidden" name="id" required value="{$data.id}"/>
                    <input type="hidden" id="team_main_id" value="{$data.team_main_id}">
                    <input type="hidden" id="team_pass_id" value="{$data.team_pass_id}">
                    <tr>
                        <th width="150">比赛时间<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control js-bootstrap-datetime" type="text" name="match_time"
                                   value="{$data.match_time}">
                        </td>
                    </tr>
                    <tr>
                        <th width="150">投注结束时间<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control js-bootstrap-datetime" type="text" {$data.status == $data::EVEMT_STATUS_RESULTFUL ? "readonly='readonly'" :''} name="bet_end_time"
                                   value="{$data.bet_end_time}">
                        </td>
                    </tr>
                    <tr>
                        <th>类型<span class="form-required">*</span></th>
                        <td>
                            <select name="lea_id" class="form-control" id="myselect" onchange="show(this[selectedIndex].value)">
                                <option value="0" <eq name="data.type" value="0"> selected</eq> >足球</option>
                                <option value="1" <eq name="data.type" value="1"> selected</eq> >篮球</option>
                                <option value="2" <eq name="data.type" value="2"> selected</eq> >电竞</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th width="150">联赛名称<span class="form-required">*</span></th>
                        <td>
                            <input class="form-control" required  type="text" name="lea_name" value="{$data.lea_name}">
                        </td>
                    </tr>
                    <tr>
                        <th>主场球队<span class="form-required">*</span></th>
                        <td class="team">
                            <select name="team_main_id" class="form-control" id="team_main" >
                                <input  type="hidden" id="main_id" value="{$data.team_main_id}">

                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>客场球队<span class="form-required">*</span></th>
                        <td class="team">
                            <select name="team_pass_id" class="form-control" id="team_pass" >
                                <input type="hidden" id="pass_id" value="{$data.team_pass_id}">
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th width="150">虚拟参与人数<span class="form-required"></span></th>
                        <td>

                            <input class="form-control" type="text" name="title" required  placeholder="请输入人数" value="{$data.fake_num}"/>
                        </td>
                    </tr>
                    <tr>
                        <th width="150">主场结果比分<span class="form-required"></span></th>
                        <td>
                            <input class="form-control" type="number" {$data.status == $data::EVEMT_STATUS_RESULTFUL ? "readonly='readonly'" :''} value="{$data.main_score}"  name="main_score"   placeholder="请输入比分"/>
                        </td>
                    </tr>
                    <tr>
                        <th width="150">客场结果比分<span class="form-required"></span></th>
                        <td>
                            <input class="form-control" type="number" {$data.status == $data::EVEMT_STATUS_RESULTFUL ? "readonly='readonly'" :''} value="{$data.pass_score}"  name="pass_score"   placeholder="请输入比分"/>
                        </td>
                    </tr>
<!--                    <tr>-->
<!--                        <th>是否推荐首页<span class="form-required"></span></th>-->
<!--                        <td>-->
<!--                            <select name="is_recommend" class="form-control">-->
<!--                                <option value="0"  >否</option>-->
<!--                                <option value="1"  {$data.is_recommend?'selected=selected':''}>是</option>-->
<!--                            </select>-->
<!--                        </td>-->
<!--                    </tr>-->
                    <tr>
                        <th>猜胜负<span class="form-required"></span></th>
                        <td>
                            <span style="margin-right:20px;">主赔率</span>
                            <input class="form-control" type="number" min="0" value="{$data.victory.v_main_odd}" name="v_main_odd"  style="width:100px;display:inline;">
                            <span style="margin-right:20px;">平赔率</span>
                            <input class="form-control" type="number" min="0" value="{$data.victory.v_middle_odd}" name="v_middle_odd"  style="width:100px;display:inline;">
                            <span style="margin-right:20px;">客赔率</span>
                            <input class="form-control" type="number" min="0" value="{$data.victory.v_pass_odd}" name="v_pass_odd"  style="width:100px;display:inline;">
                        </td>
                    </tr>
                    <tr>
                        <th>猜让球<span class="form-required"></span></th>
                        <td>
                            <span style="margin-right:20px;">主赔率</span>
                            <input class="form-control" type="number" min="0"  value="{$data.give.g_main_odd}" name="g_main_odd"  style="width:100px;display:inline;">
                            <span style="margin-right:20px;">让球名</span>
                            <input class="form-control" type="text" value="{$data.give.g_give_name}" name="g_give_name"   style="width:100px;display:inline;">
                            <span style="margin-right:20px;">让球数</span>
                            <input class="form-control" type="number" value="{$data.give.g_give_num}" name="g_give_num"  style="width:100px;display:inline;">
                            <span style="margin-right:20px;">客赔率</span>
                            <input class="form-control" type="number" min="0" value="{$data.give.g_pass_odd}" name="g_pass_odd"  style="width:100px;display:inline;">
                        </td>
                    </tr>
                    <tr>
                        <th>猜大小<span class="form-required"></span></th>
                        <td>
                            <span style="margin-right:20px;">大赔率</span>
                            <input class="form-control" type="number" min="0" value="{$data.size.s_main_odd}" name="s_main_odd"  style="width:100px;display:inline;">
                            <span style="margin-right:20px;">大小球</span>
                            <input class="form-control" type="number" min="0" value="{$data.size.s_size_num}" name="s_size_num"  style="width:100px;display:inline;">
                            <span style="margin-right:20px;">小赔率</span>
                            <input class="form-control" type="number" min="0" value="{$data.size.s_pass_odd}" name="s_pass_odd"  style="width:100px;display:inline;">
                        </td>
                    </tr>

                </table>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
                <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">

    getTeam($("#myselect").val(),$("#main_id").val(),$("#pass_id").val())
    $(function () {

        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }

        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });
    });


    function show(value) {
        getTeam(value);

    }

    function getTeam(value){
        $.ajax({
            url: '/admin/bat_match/getTeam',
            type: 'post',
            // 设置的是请求参数
            data: { type: value },
            dataType: 'json',
            success: function (obj) {
                console.log(obj)
                //每次打开一个清空一下数据，否则后面的会一直追加下去
                $("#team_main").html('');
                $("#team_pass").html('');
                if ( ! obj ) {
                    return;
                }
                //开始遍历循环数据
                for ( i = 0, len = obj.length; i < len; i++ ) {
                    item = obj[ i ];
                    //把数据进行拼接，然后追加到页面去
                    var main = "<option value=" +item['id'] ;
                    var pass = "<option value=" +item['id'] ;
                    if (item['id'] == $("#main_id").val()){
                        main += "  selected";
                    }
                    if (item['id'] == $("#pass_id").val()){
                         pass += "  selected";
                    }
                    main +=  ">" + item['team_name'] +"</option>"
                    pass +=  ">" + item['team_name'] +"</option>"
                    //进行追加遍历到页面去
                    $("#team_main").append(main);
                    $("#team_pass").append(pass);
                }
            }
        })
    }

</script>
</body>
</html>
